package com.example.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.entity.Good;
import com.example.demo.entity.ModelRes;
import com.example.demo.service.Impl.GoodServiceImpl;

@RestController
public class GoodController {
	@Autowired
	private GoodServiceImpl goodServiceImpl;

	@RequestMapping("/get-goods")
	public ModelRes<List<Good>> getAllGoods() {
		List<Good> goods = goodServiceImpl.getGoods();
		ModelRes<List<Good>> res = new ModelRes<List<Good>>();
		res.setBody(goods);
		return res;
	}

	@RequestMapping("/get-goods-upper")
	public ModelRes<List<Good>> getGoodsByUpper(float price) {
		List<Good> goods = goodServiceImpl.getGoodsUpper(price);
		ModelRes<List<Good>> res = new ModelRes<List<Good>>();
		res.setBody(goods);
		return res;
	}
}
